package net
{
	import Base.Net.NetSocket;
	
	import Common.GameNetEvent;
	import Common.GameNetManager;
	
	import flash.utils.ByteArray;
	
	import ui.RoleInfoUIHandler;

	public class ItemNetHandler
	{
		public function ItemNetHandler()
		{
			
		}
		
		public static function onRecvUseItem( data:ByteArray ):void
		{
			var mainPlayer:GamePlayer = GameManager.instance.MainPlayer;
			
			mainPlayer.data.HP = data.readShort();
			mainPlayer.data.MAXHP = data.readShort();
			mainPlayer.data.MP = data.readShort();
			mainPlayer.data.MAXMP = data.readShort();
			
			mainPlayer.data.Attack = data.readShort();
			mainPlayer.data.Defence = data.readShort();
			mainPlayer.data.Quick = data.readShort();
			mainPlayer.data.Charm = data.readShort();
			
			mainPlayer.data.Earth = data.readByte();
			mainPlayer.data.Water = data.readByte();
			mainPlayer.data.Fire = data.readByte();
			mainPlayer.data.Wind = data.readByte();
			
			RoleInfoUIHandler.instance.updateData();
		}
		
		public static function sendDropItem( i1:int , i2:int ):void
		{
			var netSocket:NetSocket = GameNetManager.instance.MainNetSocket;
			
			netSocket.writeShort( GameNetEvent.SEND_DROP_EQUIP_SIZE );
			netSocket.writeShort( GameNetEvent.SEND_DROP_EQUIP_ID );
			
			netSocket.writeShort( i1 );
			netSocket.writeShort( i2 );
			
			netSocket.Send();
		}
		
		public static function sendSwitchItem( i1:int , i2:int ):void
		{
			var netSocket:NetSocket = GameNetManager.instance.MainNetSocket;
			
			netSocket.writeShort( GameNetEvent.SEND_SWTICH_ITEM_SIZE );
			netSocket.writeShort( GameNetEvent.SEND_SWTICH_ITEM_ID );
			
			netSocket.writeShort( i1 );
			netSocket.writeShort( i2 );
			
			netSocket.Send();
		}
		
		public static function sendSwitchEquip( i1:int , i2:int ):void
		{
			var netSocket:NetSocket = GameNetManager.instance.MainNetSocket;
			
			netSocket.writeShort( GameNetEvent.SEND_SWTICH_EQUIP_SIZE );
			netSocket.writeShort( GameNetEvent.SEND_SWTICH_EQUIP_ID );
			
			netSocket.writeShort( i1 );
			netSocket.writeShort( i2 );
			
			netSocket.Send();
		}
		
		public static function sendUseItem( i:int , p:int , t:int ):void
		{
			var netSocket:NetSocket = GameNetManager.instance.MainNetSocket;
			
			netSocket.writeShort( GameNetEvent.SEND_USE_ITEM_SIZE );
			netSocket.writeShort( GameNetEvent.SEND_USE_ITEM_ID );
			
			netSocket.writeShort( i );
			netSocket.writeShort( t );
			netSocket.writeInt( p );
			
			netSocket.Send();
		}
		
		
	}
}